home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 12 / Cream of the Crop 12 (Part II) / Cream of the Crop 12 (Part II).iso / OS2 / DIKUMUD.ZIP / ACT_COMM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-30  |  10.4 KB  |  424 lines

  1. /*
  2.   SillyMUD Distribution V1.1b             (c) 1993 SillyMUD Developement
  3.  
  4.   See license.doc for distribution terms.   SillyMUD is based on DIKUMUD
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <string.h>
  9.  
  10. #include "protos.h"
  11.  
  12. /* extern variables */
  13.  
  14. extern struct room_data *world;
  15. extern struct descriptor_data *descriptor_list;
  16.  
  17.  
  18. void do_say(struct char_data *ch, char *argument, int cmd)
  19. {
  20.   int i;
  21.   char buf[MAX_INPUT_LENGTH+40];
  22.   
  23.   if (apply_soundproof(ch))
  24.     return;
  25.   
  26.   for (i = 0; *(argument + i) == ' '; i++);
  27.   
  28.   if (!*(argument + i))
  29.     send_to_char("Yes, but WHAT do you want to say?\n\r", ch);
  30.   else    {
  31.     sprintf(buf,"$n says '%s'", argument + i);
  32.     act(buf,FALSE,ch,0,0,TO_ROOM);
  33.     if (IS_NPC(ch)||(IS_SET(ch->specials.act, PLR_ECHO))) {
  34.       sprintf(buf,"You say '%s'\n\r", argument + i);
  35.       send_to_char(buf, ch);
  36.     }
  37.   }
  38. }
  39.  
  40.  
  41.  
  42.  
  43. void do_shout(struct char_data *ch, char *argument, int cmd)
  44. {
  45.   char buf1[MAX_INPUT_LENGTH+40];
  46.   struct descriptor_data *i;
  47.   extern int Silence;
  48.   
  49.   if (!IS_NPC(ch) && IS_SET(ch->specials.act, PLR_NOSHOUT)) {
  50.     send_to_char("You can't shout!!\n\r", ch);
  51.     return;
  52.   }
  53.  
  54.   if (IS_NPC(ch) && 
  55.       (Silence == 1) &&
  56.       (IS_SET(ch->specials.act, ACT_POLYSELF))) {
  57.     send_to_char("Polymorphed shouting has been banned.\n\r", ch);
  58.     send_to_char("It may return after a bit.\n\r", ch);
  59.     return;
  60.   }
  61.  
  62.   if (apply_soundproof(ch))
  63.     return;
  64.   
  65.   for (; *argument == ' '; argument++);
  66.   
  67.   if (ch->master && IS_AFFECTED(ch, AFF_CHARM)) {
  68.     if (!IS_IMMORTAL(ch->master)) {
  69.       send_to_char("I don't think so :-)", ch->master);
  70.       return;
  71.     }
  72.   }
  73.   
  74.   if (!(*argument))
  75.     send_to_char("Shout? Yes! Fine! Shout we must, but WHAT??\n\r", ch);
  76.   else    {
  77.     if (IS_NPC(ch) || IS_SET(ch->specials.act, PLR_ECHO)) {
  78.       sprintf(buf1,"You shout '%s'\n\r", argument);
  79.       send_to_char(buf1, ch);
  80.     }
  81.     sprintf(buf1, "$n shouts '%s'", argument);
  82.  
  83.     act("$n lifts up $s head and shouts loudly", FALSE, ch, 0, 0, TO_ROOM);
  84.     
  85.     GET_MOVE(ch) -= 2;
  86.     
  87.     for (i = descriptor_list; i; i = i->next)
  88.       if (i->character != ch && !i->connected &&
  89.       (IS_NPC(i->character) ||
  90.        (!IS_SET(i->character->specials.act, PLR_NOSHOUT) &&
  91.         !IS_SET(i->character->specials.act, PLR_DEAF))) &&
  92.       !check_soundproof(i->character)) {
  93.       act(buf1, 0, ch, 0, i->character, TO_VICT);
  94.       }
  95.   }
  96. }
  97.  
  98. void do_commune(struct char_data *ch, char *argument, int cmd)
  99. {
  100.   static char buf1[MAX_INPUT_LENGTH];
  101.   struct descriptor_data *i;
  102.   
  103.   
  104.   for (; *argument == ' '; argument++);
  105.   
  106.   if (!(*argument))
  107.     send_to_char("Communing among the gods is fine, but WHAT?\n\r",ch);
  108.   else {
  109.     if (IS_NPC(ch) || IS_SET(ch->specials.act, PLR_ECHO)) {
  110.       sprintf(buf1,"You think '%s'\n\r", argument);
  111.       send_to_char(buf1, ch);
  112.     }
  113.     sprintf(buf1, "$n thinks '%s'", argument);
  114.     
  115.     for (i = descriptor_list; i; i = i->next)
  116.       if (i->character != ch && !i->connected && !IS_NPC(i->character) &&
  117.       !IS_SET(i->character->specials.act, PLR_NOSHOUT) &&
  118.       (GetMaxLevel(i->character) >= LOW_IMMORTAL))
  119.     act(buf1, 0, ch, 0, i->character, TO_VICT);
  120.   }
  121. }
  122.  
  123.  
  124. void do_tell(struct char_data *ch, char *argument, int cmd)
  125. {
  126.   struct char_data *vict;
  127.   char name[100], message[MAX_INPUT_LENGTH+20],
  128.   buf[MAX_INPUT_LENGTH+60];
  129.  
  130.     if (apply_soundproof(ch))
  131.       return;
  132.   
  133.   half_chop(argument,name,message);
  134.  
  135.   if(!*name || !*message) {
  136.     send_to_char("Who do you wish to tell what??\n\r", ch);
  137.     return;
  138.   } else if (!(vict = get_char_vis(ch, name))) {
  139.     send_to_char("No-one by that name here..\n\r", ch);
  140.     return;
  141.   } else if (ch == vict) {
  142.     send_to_char("You try to tell yourself something.\n\r", ch);
  143.     return;
  144.   } else if (GET_POS(vict) == POSITION_SLEEPING)    {
  145.     act("$E is asleep, shhh.",FALSE,ch,0,vict,TO_CHAR);
  146.     return;
  147.   } else if (IS_NPC(vict) && !(vict->desc)) {
  148.     send_to_char("No-one by that name here..\n\r", ch);
  149.     return;
  150.   } else if (!vict->desc) {
  151.     send_to_char("They can't hear you, link dead.\n\r", ch);
  152.     return;
  153.   }
  154.  
  155.   if (check_soundproof(vict))
  156.       return;
  157.  
  158.   sprintf(buf,"%s tells you '%s'\n\r",
  159.       (IS_NPC(ch) ? ch->player.short_descr : GET_NAME(ch)), message);
  160.   send_to_char(buf, vict);
  161.  
  162.   if (IS_NPC(ch) || IS_SET(ch->specials.act, PLR_ECHO)) { 
  163.      sprintf(buf,"You tell %s '%s'\n\r",
  164.       (IS_NPC(vict) ? vict->player.short_descr : GET_NAME(vict)), message);
  165.      send_to_char(buf, ch);
  166.   }
  167.   
  168. }
  169.  
  170.  
  171.  
  172. void do_whisper(struct char_data *ch, char *argument, int cmd)
  173. {
  174.   struct char_data *vict;
  175.   char name[100], message[MAX_INPUT_LENGTH],
  176.   buf[MAX_INPUT_LENGTH];
  177.  
  178.     if (apply_soundproof(ch))
  179.       return;
  180.   
  181.   half_chop(argument,name,message);
  182.   
  183.   if(!*name || !*message)
  184.     send_to_char("Who do you want to whisper to.. and what??\n\r", ch);
  185.   else if (!(vict = get_char_room_vis(ch, name)))
  186.     send_to_char("No-one by that name here..\n\r", ch);
  187.   else if (vict == ch) {
  188.     act("$n whispers quietly to $mself.",FALSE,ch,0,0,TO_ROOM);
  189.     send_to_char
  190.       ("You can't seem to get your mouth close enough to your ear...\n\r",ch);
  191.   }  else    {
  192.     if (check_soundproof(vict))
  193.       return;
  194.  
  195.       sprintf(buf,"$n whispers to you, '%s'",message);
  196.       act(buf, FALSE, ch, 0, vict, TO_VICT);
  197.       if (IS_NPC(ch) || (IS_SET(ch->specials.act, PLR_ECHO))) {
  198.         sprintf(buf,"You whisper to %s, '%s'\n\r",
  199.           (IS_NPC(vict) ? vict->player.name : GET_NAME(vict)), message);
  200.         send_to_char(buf, ch);
  201.       }
  202.       act("$n whispers something to $N.", FALSE, ch, 0, vict, TO_NOTVICT);
  203.     }
  204. }
  205.  
  206.  
  207. void do_ask(struct char_data *ch, char *argument, int cmd)
  208. {
  209.   struct char_data *vict;
  210.   char name[100], message[MAX_INPUT_LENGTH],
  211.   buf[MAX_INPUT_LENGTH];
  212.  
  213.     if (apply_soundproof(ch))
  214.       return;
  215.   
  216.   half_chop(argument,name,message);
  217.   
  218.   if(!*name || !*message)
  219.     send_to_char("Who do you want to ask something.. and what??\n\r", ch);
  220.   else if (!(vict = get_char_room_vis(ch, name)))
  221.     send_to_char("No-one by that name here..\n\r", ch);
  222.   else if (vict == ch)    {
  223.     act("$n quietly asks $mself a question.",FALSE,ch,0,0,TO_ROOM);
  224.     send_to_char("You think about it for a while...\n\r", ch);
  225.   }  else    {
  226.     if (check_soundproof(vict))
  227.       return;
  228.  
  229.     sprintf(buf,"$n asks you '%s'",message);
  230.     act(buf, FALSE, ch, 0, vict, TO_VICT);
  231.     
  232.     if (IS_NPC(ch) || (IS_SET(ch->specials.act, PLR_ECHO))) {
  233.       sprintf(buf,"You ask %s, '%s'\n\r",
  234.         (IS_NPC(vict) ? vict->player.name : GET_NAME(vict)), message);
  235.       send_to_char(buf, ch);
  236.     }
  237.     act("$n asks $N a question.",FALSE,ch,0,vict,TO_NOTVICT);
  238.   }
  239. }
  240.  
  241.  
  242.  
  243. #define MAX_NOTE_LENGTH 1000      /* arbitrary */
  244.  
  245. void do_write(struct char_data *ch, char *argument, int cmd)
  246. {
  247.   struct obj_data *paper = 0, *pen = 0;
  248.   char papername[MAX_INPUT_LENGTH], penname[MAX_INPUT_LENGTH],
  249.        buf[MAX_STRING_LENGTH];
  250.   
  251.   argument_interpreter(argument, papername, penname);
  252.   
  253.   if (!ch->desc)
  254.     return;
  255.   
  256.   if (!*papername)  /* nothing was delivered */    {   
  257.       send_to_char("write (on) papername (with) penname.\n\r", ch);
  258.       return;
  259.     }
  260.  
  261.   if (!*penname) {
  262.       send_to_char("write (on) papername (with) penname.\n\r", ch);
  263.       return;
  264.   }
  265.   if (!(paper = get_obj_in_list_vis(ch, papername, ch->carrying)))    {
  266.       sprintf(buf, "You have no %s.\n\r", papername);
  267.       send_to_char(buf, ch);
  268.       return;
  269.    }
  270.    if (!(pen = get_obj_in_list_vis(ch, penname, ch->carrying)))    {
  271.       sprintf(buf, "You have no %s.\n\r", papername);
  272.       send_to_char(buf, ch);
  273.       return;
  274.     }
  275.  
  276.   /* ok.. now let's see what kind of stuff we've found */
  277.   if (pen->obj_flags.type_flag != ITEM_PEN) {
  278.       act("$p is no good for writing with.",FALSE,ch,pen,0,TO_CHAR);
  279.   } else if (paper->obj_flags.type_flag != ITEM_NOTE)    {
  280.       act("You can't write on $p.", FALSE, ch, paper, 0, TO_CHAR);
  281.   } else if (paper->action_description) {
  282.     send_to_char("There's something written on it already.\n\r", ch);
  283.     return;
  284.   } else {
  285.       /* we can write - hooray! */
  286.       send_to_char
  287.     ("Ok.. go ahead and write.. end the note with a @.\n\r", ch);
  288.       act("$n begins to jot down a note.", TRUE, ch, 0,0,TO_ROOM);
  289.       ch->desc->str = &paper->action_description;
  290.       ch->desc->max_str = MAX_NOTE_LENGTH;
  291.     }
  292. }
  293.  
  294. char *RandomWord()
  295. {
  296.   static char *string[50] = {
  297.     "argle",
  298.     "bargle",
  299.     "glop",
  300.     "glyph",
  301.     "hussamah",  /* 5 */
  302.     "rodina",
  303.     "mustafah",
  304.     "angina",
  305.     "the",
  306.     "fribble",  /* 10 */
  307.     "fnort",
  308.     "frobozz",
  309.     "zarp",
  310.     "ripple",
  311.     "yrk",    /* 15 */
  312.     "yid",
  313.     "yerf",
  314.     "oork",
  315.     "grapple",
  316.     "red",   /* 20 */
  317.     "blue",
  318.     "you",
  319.     "me",
  320.     "ftagn",
  321.     "hastur",   /* 25 */
  322.     "brob",
  323.     "gnort",
  324.     "lram",
  325.     "truck",
  326.     "kill",    /* 30 */
  327.     "cthulhu",
  328.     "huzzah",
  329.     "acetacytacylic",
  330.     "hydrooxypropyl",
  331.     "summah",     /* 35 */
  332.     "hummah",
  333.     "cookies",
  334.     "stan",
  335.     "will",
  336.     "wadapatang",   /* 40 */
  337.     "pterodactyl",
  338.     "frob",
  339.     "yuma",
  340.     "gumma",
  341.     "lo-pan",   /* 45 */
  342.     "sushi",
  343.     "yaya",
  344.     "yoyodine",
  345.     "ren",
  346.     "stimpy"   /* 50 */
  347.   };
  348.  
  349.   return(string[number(0,49)]);
  350.  
  351. }
  352.  
  353. void do_sign(struct char_data *ch, char *argument, int cmd)
  354. {
  355.   int i;
  356.   char buf[MAX_INPUT_LENGTH+40];
  357.   char buf2[MAX_INPUT_LENGTH];
  358.   char *p;
  359.   int diff;
  360.   struct char_data *t;
  361.   struct room_data *rp;
  362.     
  363.   for (i = 0; *(argument + i) == ' '; i++);
  364.   
  365.   if (!*(argument + i))
  366.     send_to_char("Yes, but WHAT do you want to sign?\n\r", ch);
  367.   else    {
  368.  
  369.     rp = real_roomp(ch->in_room);
  370.     if (!rp) return;
  371.  
  372.     if (!HasHands(ch)) {
  373.       send_to_char("Yeah right... WHAT HANDS!!!!!!!!\n\r", ch);
  374.       return;
  375.     }
  376.  
  377.     strcpy(buf, argument+i);
  378.     buf2[0] = '\0';
  379.     /*
  380.       work through the argument, word by word.  if you fail your
  381.       skill roll, the word comes out garbled.
  382.       */
  383.     p = strtok(buf, " ");  /* first word */
  384.  
  385.     diff = strlen(buf);
  386.  
  387.     while (p) {
  388.       if (ch->skills && number(1,75+strlen(p))<ch->skills[SKILL_SIGN].learned){
  389.     strcat(buf2, p);
  390.       } else {
  391.     strcat(buf2, RandomWord());
  392.       }
  393.       strcat(buf2, " ");
  394.       diff -= 1;
  395.       p = strtok(0, " ");  /* next word */
  396.     }
  397.     /*
  398.       if a recipient fails a roll, a word comes out garbled.
  399.       */
  400.  
  401.     /*
  402.       buf2 is now the "corrected" string.
  403.       */
  404.  
  405.     sprintf(buf,"$n signs '%s'", buf2);
  406.  
  407.     for (t = rp->people;t;t=t->next_in_room) {
  408.       if (t != ch) {
  409.     if (t->skills && number(1,diff) < t->skills[SKILL_SIGN].learned) {
  410.       act(buf, FALSE, ch, 0, t, TO_VICT);
  411.     } else {
  412.       act("$n makes funny motions with $s hands", 
  413.           FALSE, ch, 0, t, TO_VICT);      
  414.     }
  415.       }
  416.     }
  417.  
  418.     if (IS_NPC(ch)||(IS_SET(ch->specials.act, PLR_ECHO))) {
  419.       sprintf(buf,"You sign '%s'\n\r", argument + i);
  420.       send_to_char(buf, ch);
  421.     }
  422.   }
  423. }
  424.